//promise
var p=new Promise(function(resolved){
//在这里进行处理。也许可以使用ajax

setTimeout(function(){
   var result=10*5;
   if(result===50){
      resolve(50);
   }else{
     reject(new Error('Bad Math'));
  }
},1000);
});

p.then(function(result){
    console.log('Resolve with a values of %d',result);
});

p.catch(function(){
   console.error('Something went wrong');
});